# Why can't 0.1 be precisely represented
print(f'0.1的精确表示:{0.1:.55f}')
# Because the binary number of 0.1 is an infinite loop number.
# print(f'0.1的二进制表示:{bin(0.1):.60f}') # it's wrong
# Represent a floating-point number in binary form
bit_num = 55
a = bin(int(0.1*2**bit_num)) # Move bit_num positions to the left
print(f'0.1的二进制表示:{a}') # wrong
b = a[:2] + '0.' + '0'*(bit_num-len(a[2:])) + a[2:] # Move bit_num positions to the right
print(f'0.1的二进制表示:{b}')


